# -*- encoding=utf8 -*-
"""
RedFlag-TC000092   （拍摄进入装饰页）剪辑保存功能
剪辑减少视频时长后取消保存场景
剪辑减少视频时长后确认保存场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()
log("--------------------------------剪辑减少视频时长后取消保存场景--------------------------------------")
"""
拍摄视频进入装饰页
点击剪辑
拖动视频条
拖动视频条增加视频时长
获取此时视频时长文本
点击取消
弹窗点击取消
点击取消
弹窗点击退出
点击剪辑
获取此时视频时长文本
断言
"""

shooter.enter_photography_decoration_page()
shooter.click_element(edit_button)
sleep(1.0)
increase_new_text = shooter.get_element_text(edit_total_first_paragraph)
shooter.swipe_screen((0.8,0.75),(0.45,0.75))
shooter.slide_element_to_position(edit_video_slide_slider, (0.45, 0.745))
shooter.click_element(edit_cancel)
shooter.click_element(edit_cancel_cancel)
shooter.click_element(edit_cancel)
shooter.click_element(edit_cancel_exit)
shooter.click_element(edit_button)
increase_old_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clipTimeTV"))
shooter.assert_texts_equal(increase_new_text, increase_old_text, "断言失败，两个参数值不相等，取消失败")

log("--------------------------------剪辑减少视频时长后确认保存场景--------------------------------------")
"""
点击视频条
滑动
获取滑动后的文本
点击保存
点击剪辑
获取文本
断言
"""

shooter.swipe_screen((0.8,0.75),(0.45,0.75))
confirm_old_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clipTimeTV"))
total_old_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/selected_time_tv"))
total_old_text = total_old_text.split("/")[1].strip()
shooter.slide_element_to_position(edit_video_slide_slider, (0.45, 0.745))
shooter.click_element(edit_save)
shooter.click_element(edit_button)
sleep(1.0)
confirm_new_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clipTimeTV"))
total_new_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/selected_time_tv"))
total_new_text = total_new_text.split("/")[1].strip()
shooter.assert_texts_not_equal(confirm_old_text, confirm_new_text, "断言失败，两个参数值单个视频时长相等")
shooter.assert_texts_not_equal(total_old_text, total_new_text, "断言失败，两个参数值总视频时长不相等")

# 关闭应用
stop_app(UGC_package_name)